#pragma comment (linker, "/STACK:100000000")
#include <stdio.h>
#include <algorithm>
using namespace std;
long long A=1992919, B=18181971;
FILE *f;
char s[20];
int ts=1;
int next()
{
	A=(A*13166771+B)%1000000007;
	B=(B*67771+A)%1000000007;
	return A;
}
void createtest() { fprintf(stderr, "Test #%d\n", ts); sprintf(s, "%03d", ts); ts++; f=fopen(s, "w"); }
#define R 1000
int h[R][R];
void matr(int r, int c)
{
	int i, j;
	for(fprintf(f, "%d %d\n", r, c), i=0; i<r; fprintf(f, "\n"), i++)
		for(j=0; j<c; fprintf(f, "%d", next()%10), j++);
}
void gen0()
{
	createtest();
	fprintf(f, "6 6\n123456\n234567\n345678\n456789\n567890\n678901\n10\n1 1 0\n3 3 2\n3 2 1\n2 2 0\n4 2 0\n1 3 0\n2 3 0\n4 3 0\n5 5 1\n5 5 0\n");
	createtest();
	fprintf(f, "1 1\n1\n2\n1 1 0\n1 1 0\n");
	createtest();
	matr(3, 3);
	fprintf(f, "9\n1 1 0\n1 2 0\n1 3 0\n2 1 0\n2 2 0\n2 3 0\n3 1 0\n3 2 0\n3 3 0\n");
	createtest();
	matr(15, 10);
	fprintf(f, "6\n3 3 2\n8 3 2\n13 3 2\n3 8 2\n8 8 2\n13 8 2\n");
	createtest();
	matr(20, 23);
	fprintf(f, "7\n10 10 6\n10 11 5\n11 11 4\n10 11 3\n10 10 2\n9 10 1\n9 9 0\n");
	createtest();
	matr(23, 20);
	fprintf(f, "10\n10 10 6\n10 10 3\n5 10 1\n5 11 0\n4 10 0\n5 9 0\n10 15 1\n8 6 1\n6 8 1\n9 7 0\n");
	createtest();
	matr(100, 100);
	fprintf(f, "2\n40 40 30\n45 45 23\n");
	createtest();
	matr(100, 100);
	fprintf(f, "2\n40 40 30\n48 79 10\n");
}
bool in(int x1, int y1, int r1, int x2, int y2, int r2)
{
	return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)<=(r1-r2)*(r1-r2);
}
bool out(int x1, int y1, int r1, int x2, int y2, int r2)
{
	return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)>(r1+r2)*(r1+r2);
}
void gen1(int n)
{
	createtest();
	matr(2*R, 2*R);
	for(fprintf(f, "%d\n", n); n--; fprintf(f, "%d %d %d\n", R, R, R-1));
}
void rec2(int x, int y, int r, int &n)
{
	int i;
	if(!n) return;
	n--;
	fprintf(f, "%d %d %d\n", x, y, r);
	if(!r) return;
	rec2(x, y, r-1, n);
	for(i=1; i<r && n; i++)
		if(h[r][i]>h[r-1][i]) 
		{ 
			if(n) { fprintf(f, "%d %d %d\n", x+i, y+h[r][i], 0); n--; }
			if(n) { fprintf(f, "%d %d %d\n", x+i, y-h[r][i], 0); n--; }
			if(n) { fprintf(f, "%d %d %d\n", x-i, y+h[r][i], 0); n--; }
			if(n) { fprintf(f, "%d %d %d\n", x-i, y-h[r][i], 0); n--; }
		}
}
void gen2(int n)
{
	createtest();
	matr(2*R, 2*R);
	fprintf(f, "%d\n", n);
	rec2(R, R, R-1, n);
	for(; n--; fprintf(f, "1 1 0\n"));
}
void rec3(int x, int y, int r, int &n)
{
	int i, j;
	if(!n) return;
	n--;
	fprintf(f, "%d %d %d\n", x, y, r);
	if(!r) return;
	rec3(x, y, (r-1)/2, n);
	rec3(x-r+r/4, y, (r-2)/4, n);
	rec3(x+r-r/4, y, (r-2)/4, n);
	rec3(x, y-r+r/4, (r-2)/4, n);
	rec3(x, y+r-r/4, (r-2)/4, n);
	for(i=-r; i<=r && n; i+=2)
		for(j=-r+(i+r)/2%2; j<=r && n; j+=3)
			if(in(0, 0, r, i, j, 1) && out(0, 0, r/2, i, j, 1) && out(-r+r/4, 0, r/4, i, j, 1) && out(r-r/4, 0, r/4, i, j, 1) && out(0, -r+r/4, r/4, i, j, 1) && out(0, r-r/4, r/4, i, j, 1))
				rec3(x+i, y+j, 1, n);
}
void gen3(int n)
{
	createtest();
	matr(2*R, 2*R);
	fprintf(f, "%d\n", n);
	rec3(R, R, R-1, n);
	for(; n--; fprintf(f, "1 1 0\n"));
}
void gen4(int n)
{
	createtest();
	matr(2*R, 2*R);
	int i, j;
	fprintf(f, "%d\n", n);
	fprintf(f, "%d %d %d\n", R, R, R-1); n--;
	for(i=1; i<=2*R && n; i++)
		for(j=1; j<=2*R && n; j++)
			if(in(R, R, R-1, i, j, 0)) { n--; fprintf(f, "%d %d 0\n", i, j); }
	for(; n--; fprintf(f, "1 1 0\n"));
}
void rec5(int x, int y, int r, int &n)
{
	int i, j, t;
	if(!n) return;
	n--;
	fprintf(f, "%d %d %d\n", x, y, r);
	if(!r) return;
	for(t=r/10, i=-r+t; i+t<=r; i+=2*t+1)
		for(j=-r; j<=r; j+=2*t+1)
			if(in(0, 0, r, i, j, t)) rec5(x+i, y+j, t, n);
}
void gen5(int n)
{
	createtest();
	matr(2*R, 2*R);
	fprintf(f, "%d\n", n);
	rec5(R, R, R-1, n);
	for(; n--; fprintf(f, "1 1 0\n"));
}
int main()
{
	int i, j, k;
	for(i=0; i<R; i++)
		for(k=i, j=0; j<=i; h[i][j]=k, j++)
			for(; k*k+j*j>i*i; k--);
	gen0();
	gen1(1000000);
	gen2(1000000);
	gen3(1000000);
	gen4(1000000);
	gen5(1000000);
	return 0;
}